package com.kly.sc.api.application.service.user.impl;

import com.kly.sc.api.application.controller.system.response.SystemQARsp;
import com.kly.sc.api.application.helper.RequestLocalInfo;
import com.kly.sc.api.application.service.user.SystemQAService;
import com.kly.sc.api.application.utils.Result;
import com.kly.sc.api.application.utils.RpcUtils;
import com.kly.user.dto.SystemQaDto;
import com.kly.user.service.OtherService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

@Service
public class SystemQAServiceImpl implements SystemQAService {

    @Resource
    private OtherService otherService;

    public Result<List<SystemQARsp>> getSystemQaList(String appCode) {
        List<SystemQaDto> systemQaDtoList = RpcUtils.getResult(otherService.getSystemQaList(appCode));
        List<SystemQARsp> systemQARspList = new ArrayList<>();
        if (!systemQaDtoList.isEmpty()) {
            systemQARspList = systemQaDtoList.stream().map(SystemQARsp::toRsp).collect(Collectors.toList());
        }
        return Result.ok(systemQARspList);
    }
}
